package torque.generated;


import java.math.BigDecimal;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.ObjectUtils;
import org.apache.torque.TorqueException;
import org.apache.torque.map.TableMap;
import org.apache.torque.om.BaseObject;
import org.apache.torque.om.ComboKey;
import org.apache.torque.om.DateKey;
import org.apache.torque.om.NumberKey;
import org.apache.torque.om.ObjectKey;
import org.apache.torque.om.SimpleKey;
import org.apache.torque.om.StringKey;
import org.apache.torque.om.Persistent;
import org.apache.torque.util.Criteria;
import org.apache.torque.util.Transaction;





/**
 * Table Partie
 *
 * This class was autogenerated by Torque on:
 *
 * [Wed Mar 21 13:44:28 CET 2012]
 *
 * You should not use this class directly.  It should not even be
 * extended all references should be to Partie
 */
public abstract class BasePartie extends BaseObject
{
    /** Serial version */
    private static final long serialVersionUID = 1332333868768L;

    /** The Peer class */
    private static final PartiePeer peer =
        new PartiePeer();


    /** The value for the partieId field */
    private int partieId;

    /** The value for the nom field */
    private String nom;

    /** The value for the idplayer1 field */
    private int idplayer1;

    /** The value for the idplayer2 field */
    private int idplayer2;

    /** The value for the turn field */
    private boolean turn;

    /** The value for the taille field */
    private int taille;


    /**
     * Get the PartieId
     *
     * @return int
     */
    public int getPartieId()
    {
        return partieId;
    }


    /**
     * Set the value of PartieId
     *
     * @param v new value
     */
    public void setPartieId(int v) throws TorqueException
    {

        if (this.partieId != v)
        {
            this.partieId = v;
            setModified(true);
        }



        // update associated ObjetPartie
        if (collObjetParties != null)
        {
            for (int i = 0; i < collObjetParties.size(); i++)
            {
                ((ObjetPartie) collObjetParties.get(i))
                        .setPartieId(v);
            }
        }

        // update associated Inventaire
        if (collInventaires != null)
        {
            for (int i = 0; i < collInventaires.size(); i++)
            {
                ((Inventaire) collInventaires.get(i))
                        .setPartieId(v);
            }
        }

        // update associated VaisseauPartie
        if (collVaisseauParties != null)
        {
            for (int i = 0; i < collVaisseauParties.size(); i++)
            {
                ((VaisseauPartie) collVaisseauParties.get(i))
                        .setPartieId(v);
            }
        }
    }

    /**
     * Get the Nom
     *
     * @return String
     */
    public String getNom()
    {
        return nom;
    }


    /**
     * Set the value of Nom
     *
     * @param v new value
     */
    public void setNom(String v) 
    {

        if (!ObjectUtils.equals(this.nom, v))
        {
            this.nom = v;
            setModified(true);
        }


    }

    /**
     * Get the Idplayer1
     *
     * @return int
     */
    public int getIdplayer1()
    {
        return idplayer1;
    }


    /**
     * Set the value of Idplayer1
     *
     * @param v new value
     */
    public void setIdplayer1(int v) throws TorqueException
    {

        if (this.idplayer1 != v)
        {
            this.idplayer1 = v;
            setModified(true);
        }


        if (aPlayerRelatedByIdplayer1 != null && !(aPlayerRelatedByIdplayer1.getPlayerId() == v))
        {
            aPlayerRelatedByIdplayer1 = null;
        }

    }

    /**
     * Get the Idplayer2
     *
     * @return int
     */
    public int getIdplayer2()
    {
        return idplayer2;
    }


    /**
     * Set the value of Idplayer2
     *
     * @param v new value
     */
    public void setIdplayer2(int v) throws TorqueException
    {

        if (this.idplayer2 != v)
        {
            this.idplayer2 = v;
            setModified(true);
        }


        if (aPlayerRelatedByIdplayer2 != null && !(aPlayerRelatedByIdplayer2.getPlayerId() == v))
        {
            aPlayerRelatedByIdplayer2 = null;
        }

    }

    /**
     * Get the Turn
     *
     * @return boolean
     */
    public boolean getTurn()
    {
        return turn;
    }


    /**
     * Set the value of Turn
     *
     * @param v new value
     */
    public void setTurn(boolean v) 
    {

        if (this.turn != v)
        {
            this.turn = v;
            setModified(true);
        }


    }

    /**
     * Get the Taille
     *
     * @return int
     */
    public int getTaille()
    {
        return taille;
    }


    /**
     * Set the value of Taille
     *
     * @param v new value
     */
    public void setTaille(int v) 
    {

        if (this.taille != v)
        {
            this.taille = v;
            setModified(true);
        }


    }

    



    private Player aPlayerRelatedByIdplayer1;

    /**
     * Declares an association between this object and a Player object
     *
     * @param v Player
     * @throws TorqueException
     */
    public void setPlayerRelatedByIdplayer1(Player v) throws TorqueException
    {
        if (v == null)
        {
            setIdplayer1( 0);
        }
        else
        {
            setIdplayer1(v.getPlayerId());
        }
        aPlayerRelatedByIdplayer1 = v;
    }


    /**
     * Returns the associated Player object.
     * If it was not retrieved before, the object is retrieved from
     * the database
     *
     * @return the associated Player object
     * @throws TorqueException
     */
    public Player getPlayerRelatedByIdplayer1()
        throws TorqueException
    {
        if (aPlayerRelatedByIdplayer1 == null && (this.idplayer1 != 0))
        {
            aPlayerRelatedByIdplayer1 = PlayerPeer.retrieveByPK(SimpleKey.keyFor(this.idplayer1));
        }
        return aPlayerRelatedByIdplayer1;
    }

    /**
     * Return the associated Player object
     * If it was not retrieved before, the object is retrieved from
     * the database using the passed connection
     *
     * @param connection the connection used to retrieve the associated object
     *        from the database, if it was not retrieved before
     * @return the associated Player object
     * @throws TorqueException
     */
    public Player getPlayerRelatedByIdplayer1(Connection connection)
        throws TorqueException
    {
        if (aPlayerRelatedByIdplayer1 == null && (this.idplayer1 != 0))
        {
            aPlayerRelatedByIdplayer1 = PlayerPeer.retrieveByPK(SimpleKey.keyFor(this.idplayer1), connection);
        }
        return aPlayerRelatedByIdplayer1;
    }

    /**
     * Provides convenient way to set a relationship based on a
     * ObjectKey, for example
     * <code>bar.setFooKey(foo.getPrimaryKey())</code>
     *
     */
    public void setPlayerRelatedByIdplayer1Key(ObjectKey key) throws TorqueException
    {

        setIdplayer1(((NumberKey) key).intValue());
    }




    private Player aPlayerRelatedByIdplayer2;

    /**
     * Declares an association between this object and a Player object
     *
     * @param v Player
     * @throws TorqueException
     */
    public void setPlayerRelatedByIdplayer2(Player v) throws TorqueException
    {
        if (v == null)
        {
            setIdplayer2( 0);
        }
        else
        {
            setIdplayer2(v.getPlayerId());
        }
        aPlayerRelatedByIdplayer2 = v;
    }


    /**
     * Returns the associated Player object.
     * If it was not retrieved before, the object is retrieved from
     * the database
     *
     * @return the associated Player object
     * @throws TorqueException
     */
    public Player getPlayerRelatedByIdplayer2()
        throws TorqueException
    {
        if (aPlayerRelatedByIdplayer2 == null && (this.idplayer2 != 0))
        {
            aPlayerRelatedByIdplayer2 = PlayerPeer.retrieveByPK(SimpleKey.keyFor(this.idplayer2));
        }
        return aPlayerRelatedByIdplayer2;
    }

    /**
     * Return the associated Player object
     * If it was not retrieved before, the object is retrieved from
     * the database using the passed connection
     *
     * @param connection the connection used to retrieve the associated object
     *        from the database, if it was not retrieved before
     * @return the associated Player object
     * @throws TorqueException
     */
    public Player getPlayerRelatedByIdplayer2(Connection connection)
        throws TorqueException
    {
        if (aPlayerRelatedByIdplayer2 == null && (this.idplayer2 != 0))
        {
            aPlayerRelatedByIdplayer2 = PlayerPeer.retrieveByPK(SimpleKey.keyFor(this.idplayer2), connection);
        }
        return aPlayerRelatedByIdplayer2;
    }

    /**
     * Provides convenient way to set a relationship based on a
     * ObjectKey, for example
     * <code>bar.setFooKey(foo.getPrimaryKey())</code>
     *
     */
    public void setPlayerRelatedByIdplayer2Key(ObjectKey key) throws TorqueException
    {

        setIdplayer2(((NumberKey) key).intValue());
    }
   


    /**
     * Collection to store aggregation of collObjetParties
     */
    protected List collObjetParties;

    /**
     * Temporary storage of collObjetParties to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initObjetParties()
    {
        if (collObjetParties == null)
        {
            collObjetParties = new ArrayList();
        }
    }


    /**
     * Method called to associate a ObjetPartie object to this object
     * through the ObjetPartie foreign key attribute
     *
     * @param l ObjetPartie
     * @throws TorqueException
     */
    public void addObjetPartie(ObjetPartie l) throws TorqueException
    {
        getObjetParties().add(l);
        l.setPartie((Partie) this);
    }

    /**
     * Method called to associate a ObjetPartie object to this object
     * through the ObjetPartie foreign key attribute using connection.
     *
     * @param l ObjetPartie
     * @throws TorqueException
     */
    public void addObjetPartie(ObjetPartie l, Connection con) throws TorqueException
    {
        getObjetParties(con).add(l);
        l.setPartie((Partie) this);
    }

    /**
     * The criteria used to select the current contents of collObjetParties
     */
    private Criteria lastObjetPartiesCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getObjetParties(new Criteria())
     *
     * @return the collection of associated objects
     * @throws TorqueException
     */
    public List getObjetParties()
        throws TorqueException
    {
        if (collObjetParties == null)
        {
            collObjetParties = getObjetParties(new Criteria(10));
        }
        return collObjetParties;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Partie has previously
     * been saved, it will retrieve related ObjetParties from storage.
     * If this Partie is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getObjetParties(Criteria criteria) throws TorqueException
    {
        if (collObjetParties == null)
        {
            if (isNew())
            {
               collObjetParties = new ArrayList();
            }
            else
            {
                criteria.add(ObjetPartiePeer.PARTIE_ID, getPartieId() );
                collObjetParties = ObjetPartiePeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                criteria.add(ObjetPartiePeer.PARTIE_ID, getPartieId());
                if (!lastObjetPartiesCriteria.equals(criteria))
                {
                    collObjetParties = ObjetPartiePeer.doSelect(criteria);
                }
            }
        }
        lastObjetPartiesCriteria = criteria;

        return collObjetParties;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getObjetParties(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getObjetParties(Connection con) throws TorqueException
    {
        if (collObjetParties == null)
        {
            collObjetParties = getObjetParties(new Criteria(10), con);
        }
        return collObjetParties;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Partie has previously
     * been saved, it will retrieve related ObjetParties from storage.
     * If this Partie is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getObjetParties(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collObjetParties == null)
        {
            if (isNew())
            {
               collObjetParties = new ArrayList();
            }
            else
            {
                 criteria.add(ObjetPartiePeer.PARTIE_ID, getPartieId());
                 collObjetParties = ObjetPartiePeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                 criteria.add(ObjetPartiePeer.PARTIE_ID, getPartieId());
                 if (!lastObjetPartiesCriteria.equals(criteria))
                 {
                     collObjetParties = ObjetPartiePeer.doSelect(criteria, con);
                 }
             }
         }
         lastObjetPartiesCriteria = criteria;

         return collObjetParties;
     }











    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Partie is new, it will return
     * an empty collection; or if this Partie has previously
     * been saved, it will retrieve related ObjetParties from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Partie.
     */
    protected List getObjetPartiesJoinObjet(Criteria criteria)
        throws TorqueException
    {
        if (collObjetParties == null)
        {
            if (isNew())
            {
               collObjetParties = new ArrayList();
            }
            else
            {
                criteria.add(ObjetPartiePeer.PARTIE_ID, getPartieId());
                collObjetParties = ObjetPartiePeer.doSelectJoinObjet(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(ObjetPartiePeer.PARTIE_ID, getPartieId());
            if (!lastObjetPartiesCriteria.equals(criteria))
            {
                collObjetParties = ObjetPartiePeer.doSelectJoinObjet(criteria);
            }
        }
        lastObjetPartiesCriteria = criteria;

        return collObjetParties;
    }









    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Partie is new, it will return
     * an empty collection; or if this Partie has previously
     * been saved, it will retrieve related ObjetParties from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Partie.
     */
    protected List getObjetPartiesJoinPartie(Criteria criteria)
        throws TorqueException
    {
        if (collObjetParties == null)
        {
            if (isNew())
            {
               collObjetParties = new ArrayList();
            }
            else
            {
                criteria.add(ObjetPartiePeer.PARTIE_ID, getPartieId());
                collObjetParties = ObjetPartiePeer.doSelectJoinPartie(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(ObjetPartiePeer.PARTIE_ID, getPartieId());
            if (!lastObjetPartiesCriteria.equals(criteria))
            {
                collObjetParties = ObjetPartiePeer.doSelectJoinPartie(criteria);
            }
        }
        lastObjetPartiesCriteria = criteria;

        return collObjetParties;
    }





    /**
     * Collection to store aggregation of collInventaires
     */
    protected List collInventaires;

    /**
     * Temporary storage of collInventaires to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initInventaires()
    {
        if (collInventaires == null)
        {
            collInventaires = new ArrayList();
        }
    }


    /**
     * Method called to associate a Inventaire object to this object
     * through the Inventaire foreign key attribute
     *
     * @param l Inventaire
     * @throws TorqueException
     */
    public void addInventaire(Inventaire l) throws TorqueException
    {
        getInventaires().add(l);
        l.setPartie((Partie) this);
    }

    /**
     * Method called to associate a Inventaire object to this object
     * through the Inventaire foreign key attribute using connection.
     *
     * @param l Inventaire
     * @throws TorqueException
     */
    public void addInventaire(Inventaire l, Connection con) throws TorqueException
    {
        getInventaires(con).add(l);
        l.setPartie((Partie) this);
    }

    /**
     * The criteria used to select the current contents of collInventaires
     */
    private Criteria lastInventairesCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getInventaires(new Criteria())
     *
     * @return the collection of associated objects
     * @throws TorqueException
     */
    public List getInventaires()
        throws TorqueException
    {
        if (collInventaires == null)
        {
            collInventaires = getInventaires(new Criteria(10));
        }
        return collInventaires;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Partie has previously
     * been saved, it will retrieve related Inventaires from storage.
     * If this Partie is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getInventaires(Criteria criteria) throws TorqueException
    {
        if (collInventaires == null)
        {
            if (isNew())
            {
               collInventaires = new ArrayList();
            }
            else
            {
                criteria.add(InventairePeer.PARTIE_ID, getPartieId() );
                collInventaires = InventairePeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                criteria.add(InventairePeer.PARTIE_ID, getPartieId());
                if (!lastInventairesCriteria.equals(criteria))
                {
                    collInventaires = InventairePeer.doSelect(criteria);
                }
            }
        }
        lastInventairesCriteria = criteria;

        return collInventaires;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getInventaires(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getInventaires(Connection con) throws TorqueException
    {
        if (collInventaires == null)
        {
            collInventaires = getInventaires(new Criteria(10), con);
        }
        return collInventaires;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Partie has previously
     * been saved, it will retrieve related Inventaires from storage.
     * If this Partie is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getInventaires(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collInventaires == null)
        {
            if (isNew())
            {
               collInventaires = new ArrayList();
            }
            else
            {
                 criteria.add(InventairePeer.PARTIE_ID, getPartieId());
                 collInventaires = InventairePeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                 criteria.add(InventairePeer.PARTIE_ID, getPartieId());
                 if (!lastInventairesCriteria.equals(criteria))
                 {
                     collInventaires = InventairePeer.doSelect(criteria, con);
                 }
             }
         }
         lastInventairesCriteria = criteria;

         return collInventaires;
     }











    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Partie is new, it will return
     * an empty collection; or if this Partie has previously
     * been saved, it will retrieve related Inventaires from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Partie.
     */
    protected List getInventairesJoinVaisseau(Criteria criteria)
        throws TorqueException
    {
        if (collInventaires == null)
        {
            if (isNew())
            {
               collInventaires = new ArrayList();
            }
            else
            {
                criteria.add(InventairePeer.PARTIE_ID, getPartieId());
                collInventaires = InventairePeer.doSelectJoinVaisseau(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(InventairePeer.PARTIE_ID, getPartieId());
            if (!lastInventairesCriteria.equals(criteria))
            {
                collInventaires = InventairePeer.doSelectJoinVaisseau(criteria);
            }
        }
        lastInventairesCriteria = criteria;

        return collInventaires;
    }









    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Partie is new, it will return
     * an empty collection; or if this Partie has previously
     * been saved, it will retrieve related Inventaires from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Partie.
     */
    protected List getInventairesJoinObjet(Criteria criteria)
        throws TorqueException
    {
        if (collInventaires == null)
        {
            if (isNew())
            {
               collInventaires = new ArrayList();
            }
            else
            {
                criteria.add(InventairePeer.PARTIE_ID, getPartieId());
                collInventaires = InventairePeer.doSelectJoinObjet(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(InventairePeer.PARTIE_ID, getPartieId());
            if (!lastInventairesCriteria.equals(criteria))
            {
                collInventaires = InventairePeer.doSelectJoinObjet(criteria);
            }
        }
        lastInventairesCriteria = criteria;

        return collInventaires;
    }









    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Partie is new, it will return
     * an empty collection; or if this Partie has previously
     * been saved, it will retrieve related Inventaires from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Partie.
     */
    protected List getInventairesJoinPartie(Criteria criteria)
        throws TorqueException
    {
        if (collInventaires == null)
        {
            if (isNew())
            {
               collInventaires = new ArrayList();
            }
            else
            {
                criteria.add(InventairePeer.PARTIE_ID, getPartieId());
                collInventaires = InventairePeer.doSelectJoinPartie(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(InventairePeer.PARTIE_ID, getPartieId());
            if (!lastInventairesCriteria.equals(criteria))
            {
                collInventaires = InventairePeer.doSelectJoinPartie(criteria);
            }
        }
        lastInventairesCriteria = criteria;

        return collInventaires;
    }





    /**
     * Collection to store aggregation of collVaisseauParties
     */
    protected List collVaisseauParties;

    /**
     * Temporary storage of collVaisseauParties to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initVaisseauParties()
    {
        if (collVaisseauParties == null)
        {
            collVaisseauParties = new ArrayList();
        }
    }


    /**
     * Method called to associate a VaisseauPartie object to this object
     * through the VaisseauPartie foreign key attribute
     *
     * @param l VaisseauPartie
     * @throws TorqueException
     */
    public void addVaisseauPartie(VaisseauPartie l) throws TorqueException
    {
        getVaisseauParties().add(l);
        l.setPartie((Partie) this);
    }

    /**
     * Method called to associate a VaisseauPartie object to this object
     * through the VaisseauPartie foreign key attribute using connection.
     *
     * @param l VaisseauPartie
     * @throws TorqueException
     */
    public void addVaisseauPartie(VaisseauPartie l, Connection con) throws TorqueException
    {
        getVaisseauParties(con).add(l);
        l.setPartie((Partie) this);
    }

    /**
     * The criteria used to select the current contents of collVaisseauParties
     */
    private Criteria lastVaisseauPartiesCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getVaisseauParties(new Criteria())
     *
     * @return the collection of associated objects
     * @throws TorqueException
     */
    public List getVaisseauParties()
        throws TorqueException
    {
        if (collVaisseauParties == null)
        {
            collVaisseauParties = getVaisseauParties(new Criteria(10));
        }
        return collVaisseauParties;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Partie has previously
     * been saved, it will retrieve related VaisseauParties from storage.
     * If this Partie is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getVaisseauParties(Criteria criteria) throws TorqueException
    {
        if (collVaisseauParties == null)
        {
            if (isNew())
            {
               collVaisseauParties = new ArrayList();
            }
            else
            {
                criteria.add(VaisseauPartiePeer.PARTIE_ID, getPartieId() );
                collVaisseauParties = VaisseauPartiePeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                criteria.add(VaisseauPartiePeer.PARTIE_ID, getPartieId());
                if (!lastVaisseauPartiesCriteria.equals(criteria))
                {
                    collVaisseauParties = VaisseauPartiePeer.doSelect(criteria);
                }
            }
        }
        lastVaisseauPartiesCriteria = criteria;

        return collVaisseauParties;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getVaisseauParties(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getVaisseauParties(Connection con) throws TorqueException
    {
        if (collVaisseauParties == null)
        {
            collVaisseauParties = getVaisseauParties(new Criteria(10), con);
        }
        return collVaisseauParties;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Partie has previously
     * been saved, it will retrieve related VaisseauParties from storage.
     * If this Partie is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getVaisseauParties(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collVaisseauParties == null)
        {
            if (isNew())
            {
               collVaisseauParties = new ArrayList();
            }
            else
            {
                 criteria.add(VaisseauPartiePeer.PARTIE_ID, getPartieId());
                 collVaisseauParties = VaisseauPartiePeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                 criteria.add(VaisseauPartiePeer.PARTIE_ID, getPartieId());
                 if (!lastVaisseauPartiesCriteria.equals(criteria))
                 {
                     collVaisseauParties = VaisseauPartiePeer.doSelect(criteria, con);
                 }
             }
         }
         lastVaisseauPartiesCriteria = criteria;

         return collVaisseauParties;
     }











    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Partie is new, it will return
     * an empty collection; or if this Partie has previously
     * been saved, it will retrieve related VaisseauParties from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Partie.
     */
    protected List getVaisseauPartiesJoinVaisseau(Criteria criteria)
        throws TorqueException
    {
        if (collVaisseauParties == null)
        {
            if (isNew())
            {
               collVaisseauParties = new ArrayList();
            }
            else
            {
                criteria.add(VaisseauPartiePeer.PARTIE_ID, getPartieId());
                collVaisseauParties = VaisseauPartiePeer.doSelectJoinVaisseau(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(VaisseauPartiePeer.PARTIE_ID, getPartieId());
            if (!lastVaisseauPartiesCriteria.equals(criteria))
            {
                collVaisseauParties = VaisseauPartiePeer.doSelectJoinVaisseau(criteria);
            }
        }
        lastVaisseauPartiesCriteria = criteria;

        return collVaisseauParties;
    }









    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Partie is new, it will return
     * an empty collection; or if this Partie has previously
     * been saved, it will retrieve related VaisseauParties from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Partie.
     */
    protected List getVaisseauPartiesJoinPartie(Criteria criteria)
        throws TorqueException
    {
        if (collVaisseauParties == null)
        {
            if (isNew())
            {
               collVaisseauParties = new ArrayList();
            }
            else
            {
                criteria.add(VaisseauPartiePeer.PARTIE_ID, getPartieId());
                collVaisseauParties = VaisseauPartiePeer.doSelectJoinPartie(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(VaisseauPartiePeer.PARTIE_ID, getPartieId());
            if (!lastVaisseauPartiesCriteria.equals(criteria))
            {
                collVaisseauParties = VaisseauPartiePeer.doSelectJoinPartie(criteria);
            }
        }
        lastVaisseauPartiesCriteria = criteria;

        return collVaisseauParties;
    }



        
    private static List fieldNames = null;

    /**
     * Generate a list of field names.
     *
     * @return a list of field names
     */
    public static synchronized List getFieldNames()
    {
        if (fieldNames == null)
        {
            fieldNames = new ArrayList();
            fieldNames.add("PartieId");
            fieldNames.add("Nom");
            fieldNames.add("Idplayer1");
            fieldNames.add("Idplayer2");
            fieldNames.add("Turn");
            fieldNames.add("Taille");
            fieldNames = Collections.unmodifiableList(fieldNames);
        }
        return fieldNames;
    }

    /**
     * Retrieves a field from the object by field (Java) name passed in as a String.
     *
     * @param name field name
     * @return value
     */
    public Object getByName(String name)
    {
        if (name.equals("PartieId"))
        {
            return new Integer(getPartieId());
        }
        if (name.equals("Nom"))
        {
            return getNom();
        }
        if (name.equals("Idplayer1"))
        {
            return new Integer(getIdplayer1());
        }
        if (name.equals("Idplayer2"))
        {
            return new Integer(getIdplayer2());
        }
        if (name.equals("Turn"))
        {
            return new Boolean(getTurn());
        }
        if (name.equals("Taille"))
        {
            return new Integer(getTaille());
        }
        return null;
    }

    /**
     * Set a field in the object by field (Java) name.
     *
     * @param name field name
     * @param value field value
     * @return True if value was set, false if not (invalid name / protected field).
     * @throws IllegalArgumentException if object type of value does not match field object type.
     * @throws TorqueException If a problem occurs with the set[Field] method.
     */
    public boolean setByName(String name, Object value )
        throws TorqueException, IllegalArgumentException
    {
        if (name.equals("PartieId"))
        {
            if (value == null || ! (Integer.class.isInstance(value)))
            {
                throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
            }
            setPartieId(((Integer) value).intValue());
            return true;
        }
        if (name.equals("Nom"))
        {
            // Object fields can be null
            if (value != null && ! String.class.isInstance(value))
            {
                throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
            }
            setNom((String) value);
            return true;
        }
        if (name.equals("Idplayer1"))
        {
            if (value == null || ! (Integer.class.isInstance(value)))
            {
                throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
            }
            setIdplayer1(((Integer) value).intValue());
            return true;
        }
        if (name.equals("Idplayer2"))
        {
            if (value == null || ! (Integer.class.isInstance(value)))
            {
                throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
            }
            setIdplayer2(((Integer) value).intValue());
            return true;
        }
        if (name.equals("Turn"))
        {
            if (value == null || ! (Boolean.class.isInstance(value)))
            {
                throw new IllegalArgumentException("setByName: value parameter was null or not a Boolean object.");
            }
            setTurn(((Boolean)value).booleanValue());
            return true;
        }
        if (name.equals("Taille"))
        {
            if (value == null || ! (Integer.class.isInstance(value)))
            {
                throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
            }
            setTaille(((Integer) value).intValue());
            return true;
        }
        return false;
    }

    /**
     * Retrieves a field from the object by name passed in
     * as a String.  The String must be one of the static
     * Strings defined in this Class' Peer.
     *
     * @param name peer name
     * @return value
     */
    public Object getByPeerName(String name)
    {
        if (name.equals(PartiePeer.PARTIE_ID))
        {
            return new Integer(getPartieId());
        }
        if (name.equals(PartiePeer.NOM))
        {
            return getNom();
        }
        if (name.equals(PartiePeer.IDPLAYER1))
        {
            return new Integer(getIdplayer1());
        }
        if (name.equals(PartiePeer.IDPLAYER2))
        {
            return new Integer(getIdplayer2());
        }
        if (name.equals(PartiePeer.TURN))
        {
            return new Boolean(getTurn());
        }
        if (name.equals(PartiePeer.TAILLE))
        {
            return new Integer(getTaille());
        }
        return null;
    }

    /**
     * Set field values by Peer Field Name
     *
     * @param name field name
     * @param value field value
     * @return True if value was set, false if not (invalid name / protected field).
     * @throws IllegalArgumentException if object type of value does not match field object type.
     * @throws TorqueException If a problem occurs with the set[Field] method.
     */
    public boolean setByPeerName(String name, Object value)
        throws TorqueException, IllegalArgumentException
    {
      if (PartiePeer.PARTIE_ID.equals(name))
        {
            return setByName("PartieId", value);
        }
      if (PartiePeer.NOM.equals(name))
        {
            return setByName("Nom", value);
        }
      if (PartiePeer.IDPLAYER1.equals(name))
        {
            return setByName("Idplayer1", value);
        }
      if (PartiePeer.IDPLAYER2.equals(name))
        {
            return setByName("Idplayer2", value);
        }
      if (PartiePeer.TURN.equals(name))
        {
            return setByName("Turn", value);
        }
      if (PartiePeer.TAILLE.equals(name))
        {
            return setByName("Taille", value);
        }
        return false;
    }

    /**
     * Retrieves a field from the object by Position as specified
     * in the xml schema.  Zero-based.
     *
     * @param pos position in xml schema
     * @return value
     */
    public Object getByPosition(int pos)
    {
        if (pos == 0)
        {
            return new Integer(getPartieId());
        }
        if (pos == 1)
        {
            return getNom();
        }
        if (pos == 2)
        {
            return new Integer(getIdplayer1());
        }
        if (pos == 3)
        {
            return new Integer(getIdplayer2());
        }
        if (pos == 4)
        {
            return new Boolean(getTurn());
        }
        if (pos == 5)
        {
            return new Integer(getTaille());
        }
        return null;
    }

    /**
     * Set field values by its position (zero based) in the XML schema.
     *
     * @param position The field position
     * @param value field value
     * @return True if value was set, false if not (invalid position / protected field).
     * @throws IllegalArgumentException if object type of value does not match field object type.
     * @throws TorqueException If a problem occurs with the set[Field] method.
     */
    public boolean setByPosition(int position, Object value)
        throws TorqueException, IllegalArgumentException
    {
    if (position == 0)
        {
            return setByName("PartieId", value);
        }
    if (position == 1)
        {
            return setByName("Nom", value);
        }
    if (position == 2)
        {
            return setByName("Idplayer1", value);
        }
    if (position == 3)
        {
            return setByName("Idplayer2", value);
        }
    if (position == 4)
        {
            return setByName("Turn", value);
        }
    if (position == 5)
        {
            return setByName("Taille", value);
        }
        return false;
    }
     
    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     *
     * @throws Exception
     */
    public void save() throws Exception
    {
        save(PartiePeer.DATABASE_NAME);
    }

    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     * Note: this code is here because the method body is
     * auto-generated conditionally and therefore needs to be
     * in this file instead of in the super class, BaseObject.
     *
     * @param dbName
     * @throws TorqueException
     */
    public void save(String dbName) throws TorqueException
    {
        Connection con = null;
        try
        {
            con = Transaction.begin(dbName);
            save(con);
            Transaction.commit(con);
        }
        catch(TorqueException e)
        {
            Transaction.safeRollback(con);
            throw e;
        }
    }

    /** flag to prevent endless save loop, if this object is referenced
        by another object which falls in this transaction. */
    private boolean alreadyInSave = false;
    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.  This method
     * is meant to be used as part of a transaction, otherwise use
     * the save() method and the connection details will be handled
     * internally
     *
     * @param con
     * @throws TorqueException
     */
    public void save(Connection con) throws TorqueException
    {
        if (!alreadyInSave)
        {
            alreadyInSave = true;



            // If this object has been modified, then save it to the database.
            if (isModified())
            {
                if (isNew())
                {
                    PartiePeer.doInsert((Partie) this, con);
                    setNew(false);
                }
                else
                {
                    PartiePeer.doUpdate((Partie) this, con);
                }
            }


            if (collObjetParties != null)
            {
                for (int i = 0; i < collObjetParties.size(); i++)
                {
                    ((ObjetPartie) collObjetParties.get(i)).save(con);
                }
            }

            if (collInventaires != null)
            {
                for (int i = 0; i < collInventaires.size(); i++)
                {
                    ((Inventaire) collInventaires.get(i)).save(con);
                }
            }

            if (collVaisseauParties != null)
            {
                for (int i = 0; i < collVaisseauParties.size(); i++)
                {
                    ((VaisseauPartie) collVaisseauParties.get(i)).save(con);
                }
            }
            alreadyInSave = false;
        }
    }


    /**
     * Set the PrimaryKey using ObjectKey.
     *
     * @param key partieId ObjectKey
     */
    public void setPrimaryKey(ObjectKey key)
        throws TorqueException
    {
        setPartieId(((NumberKey) key).intValue());
    }

    /**
     * Set the PrimaryKey using a String.
     *
     * @param key
     */
    public void setPrimaryKey(String key) throws TorqueException
    {
        setPartieId(Integer.parseInt(key));
    }


    /**
     * returns an id that differentiates this object from others
     * of its class.
     */
    public ObjectKey getPrimaryKey()
    {
        return SimpleKey.keyFor(getPartieId());
    }
 

    /**
     * Makes a copy of this object.
     * It creates a new object filling in the simple attributes.
     * It then fills all the association collections and sets the
     * related objects to isNew=true.
     */
    public Partie copy() throws TorqueException
    {
        return copy(true);
    }

    /**
     * Makes a copy of this object using connection.
     * It creates a new object filling in the simple attributes.
     * It then fills all the association collections and sets the
     * related objects to isNew=true.
     *
     * @param con the database connection to read associated objects.
     */
    public Partie copy(Connection con) throws TorqueException
    {
        return copy(true, con);
    }

    /**
     * Makes a copy of this object.
     * It creates a new object filling in the simple attributes.
     * If the parameter deepcopy is true, it then fills all the
     * association collections and sets the related objects to
     * isNew=true.
     *
     * @param deepcopy whether to copy the associated objects.
     */
    public Partie copy(boolean deepcopy) throws TorqueException
    {
        return copyInto(new Partie(), deepcopy);
    }

    /**
     * Makes a copy of this object using connection.
     * It creates a new object filling in the simple attributes.
     * If the parameter deepcopy is true, it then fills all the
     * association collections and sets the related objects to
     * isNew=true.
     *
     * @param deepcopy whether to copy the associated objects.
     * @param con the database connection to read associated objects.
     */
    public Partie copy(boolean deepcopy, Connection con) throws TorqueException
    {
        return copyInto(new Partie(), deepcopy, con);
    }
  
    /**
     * Fills the copyObj with the contents of this object.
     * The associated objects are also copied and treated as new objects.
     *
     * @param copyObj the object to fill.
     */
    protected Partie copyInto(Partie copyObj) throws TorqueException
    {
        return copyInto(copyObj, true);
    }

  
    /**
     * Fills the copyObj with the contents of this object using connection.
     * The associated objects are also copied and treated as new objects.
     *
     * @param copyObj the object to fill.
     * @param con the database connection to read associated objects.
     */
    protected Partie copyInto(Partie copyObj, Connection con) throws TorqueException
    {
        return copyInto(copyObj, true, con);
    }
  
    /**
     * Fills the copyObj with the contents of this object.
     * If deepcopy is true, The associated objects are also copied
     * and treated as new objects.
     *
     * @param copyObj the object to fill.
     * @param deepcopy whether the associated objects should be copied.
     */
    protected Partie copyInto(Partie copyObj, boolean deepcopy) throws TorqueException
    {
        copyObj.setPartieId(partieId);
        copyObj.setNom(nom);
        copyObj.setIdplayer1(idplayer1);
        copyObj.setIdplayer2(idplayer2);
        copyObj.setTurn(turn);
        copyObj.setTaille(taille);

        copyObj.setPartieId( 0);

        if (deepcopy)
        {


        List vObjetParties = getObjetParties();
        if (vObjetParties != null)
        {
            for (int i = 0; i < vObjetParties.size(); i++)
            {
                ObjetPartie obj = (ObjetPartie) vObjetParties.get(i);
                copyObj.addObjetPartie(obj.copy());
            }
        }
        else
        {
            copyObj.collObjetParties = null;
        }


        List vInventaires = getInventaires();
        if (vInventaires != null)
        {
            for (int i = 0; i < vInventaires.size(); i++)
            {
                Inventaire obj = (Inventaire) vInventaires.get(i);
                copyObj.addInventaire(obj.copy());
            }
        }
        else
        {
            copyObj.collInventaires = null;
        }


        List vVaisseauParties = getVaisseauParties();
        if (vVaisseauParties != null)
        {
            for (int i = 0; i < vVaisseauParties.size(); i++)
            {
                VaisseauPartie obj = (VaisseauPartie) vVaisseauParties.get(i);
                copyObj.addVaisseauPartie(obj.copy());
            }
        }
        else
        {
            copyObj.collVaisseauParties = null;
        }
        }
        return copyObj;
    }
        
    
    /**
     * Fills the copyObj with the contents of this object using connection.
     * If deepcopy is true, The associated objects are also copied
     * and treated as new objects.
     *
     * @param copyObj the object to fill.
     * @param deepcopy whether the associated objects should be copied.
     * @param con the database connection to read associated objects.
     */
    protected Partie copyInto(Partie copyObj, boolean deepcopy, Connection con) throws TorqueException
    {
        copyObj.setPartieId(partieId);
        copyObj.setNom(nom);
        copyObj.setIdplayer1(idplayer1);
        copyObj.setIdplayer2(idplayer2);
        copyObj.setTurn(turn);
        copyObj.setTaille(taille);

        copyObj.setPartieId( 0);

        if (deepcopy)
        {


        List vObjetParties = getObjetParties(con);
        if (vObjetParties != null)
        {
            for (int i = 0; i < vObjetParties.size(); i++)
            {
                ObjetPartie obj = (ObjetPartie) vObjetParties.get(i);
                copyObj.addObjetPartie(obj.copy(con), con);
            }
        }
        else
        {
            copyObj.collObjetParties = null;
        }


        List vInventaires = getInventaires(con);
        if (vInventaires != null)
        {
            for (int i = 0; i < vInventaires.size(); i++)
            {
                Inventaire obj = (Inventaire) vInventaires.get(i);
                copyObj.addInventaire(obj.copy(con), con);
            }
        }
        else
        {
            copyObj.collInventaires = null;
        }


        List vVaisseauParties = getVaisseauParties(con);
        if (vVaisseauParties != null)
        {
            for (int i = 0; i < vVaisseauParties.size(); i++)
            {
                VaisseauPartie obj = (VaisseauPartie) vVaisseauParties.get(i);
                copyObj.addVaisseauPartie(obj.copy(con), con);
            }
        }
        else
        {
            copyObj.collVaisseauParties = null;
        }
        }
        return copyObj;
    }
    
    

    /**
     * returns a peer instance associated with this om.  Since Peer classes
     * are not to have any instance attributes, this method returns the
     * same instance for all member of this class. The method could therefore
     * be static, but this would prevent one from overriding the behavior.
     */
    public PartiePeer getPeer()
    {
        return peer;
    }

    /**
     * Retrieves the TableMap object related to this Table data without
     * compiler warnings of using getPeer().getTableMap().
     *
     * @return The associated TableMap object.
     */
    public TableMap getTableMap() throws TorqueException
    {
        return PartiePeer.getTableMap();
    }


    public String toString()
    {
        StringBuffer str = new StringBuffer();
        str.append("Partie:\n");
        str.append("PartieId = ")
           .append(getPartieId())
           .append("\n");
        str.append("Nom = ")
           .append(getNom())
           .append("\n");
        str.append("Idplayer1 = ")
           .append(getIdplayer1())
           .append("\n");
        str.append("Idplayer2 = ")
           .append(getIdplayer2())
           .append("\n");
        str.append("Turn = ")
           .append(getTurn())
           .append("\n");
        str.append("Taille = ")
           .append(getTaille())
           .append("\n");
        return(str.toString());
    }
}
